package tech.six6.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.six6.dao.MybatisSpringDao;
import tech.six6.entity.MybatisSpring;
import tech.six6.service.MybatisSpringService;

import java.util.List;

@Service("mybatisSpringService")
public class MybatisSpringServiceImpl implements MybatisSpringService {

   @Autowired
//    @Resource(name="mybatisSpringDao")
    private MybatisSpringDao mybatisSpringDao;

    @Override
    public int add(MybatisSpring demo) {
        if (demo == null){
            return 0;
        }
        return mybatisSpringDao.add(demo);
    }

    @Override
    public int delete(int id) {
        return mybatisSpringDao.delete(id);
    }

    @Override
    public int update(MybatisSpring demo) {
        if (demo.getName()==null && demo.getPassword()==null && demo.getSex()==null){
            return 0;
        }
        return mybatisSpringDao.update(demo);
    }

    @Override
    public MybatisSpring selectById(int id) {
        return mybatisSpringDao.selectById(id);
    }

    @Override
    public List<MybatisSpring> selectAll() {
        return mybatisSpringDao.selectAll();
    }
}
